package com.officegameapp.service;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.officegameapp.db.dao.DAOFactory;
import com.officegameapp.db.dao.ITeamDAO;
import com.officegameapp.db.entities.Team;

@Path("/teams")
public class TeamService {

	private ITeamDAO teamDAO;

	public TeamService() {
		teamDAO = DAOFactory.getDAOFactory(DAOFactory.MYSQL_DAO).getTeamDAO();
	}

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Team> getTeams() {
		List<Team> list = teamDAO.getTeams();
		return list;
	}
	
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_JSON)
	public Team createTeam(Team team) {
		teamDAO.persist(team);
		return team;
	}

}
